home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 701-725 / 708 / intuisup / intuisup42.lha / Intuisup / source.lha / Borders / borders_test.c next >
C/C++ Source or Header  |  1992-04-08  |  5KB  |  170 lines

  1. /* $Revision Header *** Header built automatically - do not edit! ***********
  2.  *
  3.  *    (C) Copyright 1991 by Torsten Jürgeleit
  4.  *
  5.  *    Name .....: borders_test.c
  6.  *    Created ..: Thursday 19-Dec-91 17:26:00
  7.  *    Revision .: 0
  8.  *
  9.  *    Date        Author                 Comment
  10.  *    =========   ====================   ====================
  11.  *    19-Dec-91   Torsten Jürgeleit      Created this file!
  12.  *
  13.  ****************************************************************************
  14.  *
  15.  *    Test of border functions
  16.  *
  17.  * $Revision Header ********************************************************/
  18.  
  19.     /* Includes */
  20.  
  21. #include <exec/types.h>
  22. #include <graphics/gfxbase.h>
  23. #include <intuition/intuitionbase.h>
  24. #include <intuition/intuition.h>
  25. #ifdef AZTEC_C
  26. #include <functions.h>   /* needed for Aztec C - prototypes and pragmas for all Amiga system functions */
  27. #endif
  28. #include <libraries/memwatch.h>   /* header file for memory debug link library (Fish 240) - AFTER functions.h */
  29. #include "/render/render.h"
  30. #include "borders.h"
  31.  
  32.     /* Defines */
  33.  
  34. #define WINDOW_WIDTH        600
  35. #define WINDOW_HEIGHT        180
  36. #define WINDOW_IDCMP        CLOSEWINDOW
  37. #define WINDOW_FLAGS        (WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE)
  38. #define WINDOW_TITLE        (UBYTE *)" Borders test "
  39.  
  40. #define RENDER_INFO_FLAGS    (USHORT)(RENDER_INFO_FLAG_INNER_WINDOW | RENDER_INFO_FLAG_BACK_FILL)
  41. #define OPEN_WINDOW_FLAGS    (USHORT)(OPEN_WINDOW_FLAG_CENTER_WINDOW | OPEN_WINDOW_FLAG_RENDER_PENS)
  42.  
  43.     /* Globals */
  44.  
  45. struct IntuitionBase  *IntuitionBase;
  46. struct GfxBase        *GfxBase;
  47. struct Library        *DiskfontBase;
  48.  
  49.     /* Statics */
  50.  
  51. STATIC struct NewWindow  test_new_window = {
  52.    0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0, 0, WINDOW_IDCMP, WINDOW_FLAGS,
  53.    NULL, NULL, WINDOW_TITLE, NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
  54. };
  55.     /* Defines for test borders */
  56.  
  57. #define TEST_BORDER1_TYPE        BORDER_DATA_TYPE_BOX1_IN
  58. #define TEST_BORDER1_LEFT_EDGE        ((WINDOW_WIDTH - TEST_BORDER1_WIDTH) / 2)
  59. #define TEST_BORDER1_TOP_EDGE        20
  60. #define TEST_BORDER1_WIDTH        (WINDOW_WIDTH / 2)
  61. #define TEST_BORDER1_HEIGHT        (WINDOW_HEIGHT - 2 * TEST_BORDER1_TOP_EDGE)
  62.  
  63. #define TEST_BORDER2_TYPE        BORDER_DATA_TYPE_BOX2_IN
  64. #define TEST_BORDER2_LEFT_EDGE        ((WINDOW_WIDTH - TEST_BORDER2_WIDTH) / 2)
  65. #define TEST_BORDER2_TOP_EDGE        40
  66. #define TEST_BORDER2_WIDTH        (WINDOW_WIDTH / 3)
  67. #define TEST_BORDER2_HEIGHT        (WINDOW_HEIGHT - 2 * TEST_BORDER2_TOP_EDGE)
  68.  
  69. #define TEST_BORDER3_TYPE        BORDER_DATA_TYPE_BOX1_OUT
  70. #define TEST_BORDER3_LEFT_EDGE        ((WINDOW_WIDTH - TEST_BORDER3_WIDTH) / 2)
  71. #define TEST_BORDER3_TOP_EDGE        60
  72. #define TEST_BORDER3_WIDTH        (WINDOW_WIDTH / 4)
  73. #define TEST_BORDER3_HEIGHT        (WINDOW_HEIGHT - 2 * TEST_BORDER3_TOP_EDGE)
  74.  
  75. #define TEST_BORDER4_TYPE        BORDER_DATA_TYPE_BOX2_OUT
  76. #define TEST_BORDER4_LEFT_EDGE        ((WINDOW_WIDTH - TEST_BORDER4_WIDTH) / 2)
  77. #define TEST_BORDER4_TOP_EDGE        80
  78. #define TEST_BORDER4_WIDTH        (WINDOW_WIDTH / 8)
  79. #define TEST_BORDER4_HEIGHT        (WINDOW_HEIGHT - 2 * TEST_BORDER4_TOP_EDGE)
  80.  
  81.     /* Statics for test borders */
  82.  
  83. STATIC struct BorderData  test_border_data[] = {
  84.    {
  85.     TEST_BORDER1_TYPE,        /* bd_Type */
  86.     TEST_BORDER1_LEFT_EDGE,        /* bd_LeftEdge */
  87.     TEST_BORDER1_TOP_EDGE,        /* bd_TopEdge */
  88.     TEST_BORDER1_WIDTH,        /* bd_Width */
  89.     TEST_BORDER1_HEIGHT        /* bd_Height */
  90.    }, {
  91.     TEST_BORDER2_TYPE,        /* bd_Type */
  92.     TEST_BORDER2_LEFT_EDGE,        /* bd_LeftEdge */
  93.     TEST_BORDER2_TOP_EDGE,        /* bd_TopEdge */
  94.     TEST_BORDER2_WIDTH,        /* bd_Width */
  95.     TEST_BORDER2_HEIGHT        /* bd_Height */
  96.    }, {
  97.     TEST_BORDER3_TYPE,        /* bd_Type */
  98.     TEST_BORDER3_LEFT_EDGE,        /* bd_LeftEdge */
  99.     TEST_BORDER3_TOP_EDGE,        /* bd_TopEdge */
  100.     TEST_BORDER3_WIDTH,        /* bd_Width */
  101.     TEST_BORDER3_HEIGHT        /* bd_Height */
  102.    }, {
  103.     TEST_BORDER4_TYPE,        /* bd_Type */
  104.     TEST_BORDER4_LEFT_EDGE,        /* bd_LeftEdge */
  105.     TEST_BORDER4_TOP_EDGE,        /* bd_TopEdge */
  106.     TEST_BORDER4_WIDTH,        /* bd_Width */
  107.     TEST_BORDER4_HEIGHT        /* bd_Height */
  108.    }, {
  109.     INTUISUP_DATA_END        /* mark end of border data array */
  110.    }
  111. };
  112.     /* Prototypes */
  113.  
  114. VOID test_action(struct RenderInfo  *ri, struct Window  *win);
  115.  
  116.     /* Pragmas */
  117.  
  118. #pragma regcall(test_action(a0,a1))
  119.  
  120.     /* Borders test */
  121.  
  122.    LONG
  123. main(VOID)
  124. {
  125.    struct RenderInfo  *ri;
  126.    struct Window      *win;
  127.  
  128.    MWInit((BPTR)NULL, 0L);
  129.    if (IntuitionBase = OpenLibrary("intuition.library", 0L)) {
  130.       if (GfxBase = OpenLibrary("graphics.library", 0L)) {
  131.      if (DiskfontBase = OpenLibrary("diskfont.library", 0L)) {
  132.         if (ri = get_render_info(NULL, RENDER_INFO_FLAGS)) {
  133.            if (win = open_window(ri, &test_new_window,
  134.                                OPEN_WINDOW_FLAGS)) {
  135.           test_action(ri, win);
  136.           close_window(win, FALSE);
  137.            }
  138.            free_render_info(ri);
  139.         }
  140.         CloseLibrary(DiskfontBase);
  141.      }
  142.      CloseLibrary(GfxBase);
  143.       }
  144.       CloseLibrary(IntuitionBase);
  145.    }
  146.    MWTerm();
  147.    return(0L);
  148. }
  149.     /* Perform IDCMP action */
  150.  
  151.    VOID
  152. test_action(struct RenderInfo  *ri, struct Window  *win)
  153. {
  154.    struct MsgPort  *up = win->UserPort;
  155.    BOOL keepon = TRUE;
  156.  
  157.    display_borders(ri, win, &test_border_data[0], -0, -0);
  158.    do {
  159.       struct IntuiMessage  *msg;
  160.  
  161.       WaitPort(up);
  162.       while (msg = (struct IntuiMessage *)GetMsg(up)) {
  163.      if (msg->Class == CLOSEWINDOW) {
  164.         keepon = FALSE;
  165.      }
  166.      ReplyMsg((struct Message *)msg);
  167.       }
  168.    } while (keepon == TRUE);
  169. }
  170.